#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int findPoisonedDuration(vector<int>& timeSeries, int duration) {
        int ret = 0;
        for (int i = 1; i < timeSeries.size(); i++)
        {
            int x = timeSeries[i] - timeSeries[i - 1];
            if (x >= duration)   ret += duration;
            else ret += x;
        }
        return ret + duration;
    }
};